package cxm.exam.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import me.drakeet.meizhi.R;

/**
 * Created by ThinkPad on 2017/5/11.
 */

public class RecyclerViewListAdapter extends RecyclerView.Adapter<RecyclerViewListAdapter.MyViewHolder>{
    Context mContext;
    List<String> mStrArrayList = new ArrayList<>();
    public RecyclerViewListAdapter(Context context,List<String> inData){
            this.mContext = context;
            this.mStrArrayList = inData;
    }

    @Override
    public RecyclerViewListAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder holder = new MyViewHolder(LayoutInflater.from(
                mContext).inflate(R.layout.test_recycle_list_item, parent,
                false));
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerViewListAdapter.MyViewHolder holder, int position) {
        holder.tvShow.setText(mStrArrayList.get(position));
    }

    @Override
    public int getItemCount() {
        return mStrArrayList.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        TextView tvShow;
        public MyViewHolder(View itemView) {
            super(itemView);
            tvShow = (TextView)itemView.findViewById(R.id.list_item);
        }

    }
}
